import { Component, OnInit } from '@angular/core';

import { Http, Jsonp } from '@angular/http';

@Component({
  selector: 'app-weather',
  templateUrl: './weather.component.html',
  styleUrls: ['./weather.component.less']
})
export class WeatherComponent implements OnInit {
  weatherUrl = 'http://route.showapi.com/833-1';
  appId = '59518';
  key = '081696f7b0994b089348fa40df109fff';
  // showPosition: any;
  showError: any;
  getCurrentPosition: any;
  lat: any;
  lag: any;
  getLocation() {
    if (navigator.geolocation) {
      // navigator.geolocation.getCurrentPosition(showPosition);
      alert('成功');
    } else {
      alert('浏览器不支持地理定位。');
    }
  }

  showPosition(position) {
    this.lat = position.coords.latitude;
    this.lag = position.coords.longitude;
    alert('纬度:' + this.lag + ',经度:' + this.lag);
}




  constructor(private http: Http, private jsonp: Jsonp) {
    // this.http.get('')
    //   .subscribe(function (data) {
    //     console.log(data);
    //   }, function (err) {
    //     console.log(err);
    //   });
  }
  ngOnInit() {
  }

}
